package com.joysw.ui.fragment;

import butterknife.ButterKnife;
import butterknife.InjectView;

import com.google.gson.Gson;
import com.joysw.R;
import com.joysw.models.DtqModelMsg;
import com.joysw.ui.adapter.DtqListAdapter;
import com.joysw.view.TitleBarView;

import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

/**   
 * @Title: DtqFrgment.java 
 * @Package com.joysw.ui.fragment 
 * @Description: 分享的动态
 * @author LIMINGYAN  
 * @date 2015年3月28日 下午9:27:29 
 * @version V1.0   
 */
public class FxjlTabOneFrgment extends BaseFragment{
	private static final String TAG = "FxjlTabOneFrgment";
	private Context mContext;
	private View mBaseView;
	
	@InjectView(R.id.fxjl_tab_one_list)
	ListView mListView;
	
	private DtqListAdapter mAdapter;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mContext = getActivity();
		mBaseView = inflater.inflate(R.layout.fragment_fxjl_tab_one, container,
				false);
		ButterKnife.inject(this, mBaseView);
		initView();
		
		new MyTask().execute();
		return mBaseView;
	}
	
	private void initView(){

	}
	
	class MyTask extends AsyncTask<Void, Void, DtqModelMsg> {

		@Override
		protected DtqModelMsg doInBackground(Void... params) {
			String json = "{\"code\":200,\"msg\":\"ok\",list:["
					+ "{\"id\":110,\"avator\":\"http://img0.bdstatic.com/img/image/shouye/leimu/mingxing.jpg\",\"name\":\"微分销官方客服老王\",\"content\":\"各位微分销用户，你们好啊！\",\"urls\":[]},"
					+ "{\"id\":111,\"avator\":\"http://img0.bdstatic.com/img/image/shouye/leimu/mingxing2.jpg\",\"name\":\"柠檬食品分销官\",\"content\":\"亲们，柠檬大龙到货，价格便宜，质量好。欢迎大家前来团购\",\"urls\":[\"http://d.hiphotos.baidu.com/album/w%3D2048/sign=14b0934b78310a55c424d9f4837d42a9/a8014c086e061d95e9fd3e807af40ad163d9cacb.jpg\"]},"
					+ "{\"id\":112,\"avator\":\"http://img0.bdstatic.com/img/image/shouye/leimu/mingxing1.jpg\",\"name\":\"简单部落\",\"content\":\"简单美丽，大方使我们的追求！\",\"urls\":[\"http://g.hiphotos.bdimg.com/album/s%3D680%3Bq%3D90/sign=ccd33b46d53f8794d7ff4b26e2207fc9/0d338744ebf81a4c0f993437d62a6059242da6a1.jpg\",\"http://c.hiphotos.bdimg.com/album/s%3D900%3Bq%3D90/sign=b8658f17f3d3572c62e290dcba28121a/5fdf8db1cb134954bb97309a574e9258d0094a47.jpg\"]},"
					+ "{\"id\":113,\"avator\":\"http://img0.bdstatic.com/img/image/shouye/leimu/mingxing6.jpg\",\"name\":\"美丽衣冠\",\"content\":\"一款翻领的衬衫，文艺小清新。多种颜色，喜欢就来吧！\",\"urls\":[\"http://g.hiphotos.bdimg.com/album/s%3D680%3Bq%3D90/sign=ccd33b46d53f8794d7ff4b26e2207fc9/0d338744ebf81a4c0f993437d62a6059242da6a1.jpg\",\"http://g.hiphotos.bdimg.com/album/s%3D680%3Bq%3D90/sign=ccd33b46d53f8794d7ff4b26e2207fc9/0d338744ebf81a4c0f993437d62a6059242da6a1.jpg\",\"http://f.hiphotos.bdimg.com/album/s%3D680%3Bq%3D90/sign=6b62f61bac6eddc422e7b7f309e0c7c0/6159252dd42a2834510deef55ab5c9ea14cebfa1.jpg\",\"http://g.hiphotos.bdimg.com/album/s%3D680%3Bq%3D90/sign=e58fb67bc8ea15ce45eee301863b4bce/a5c27d1ed21b0ef4fd6140a0dcc451da80cb3e47.jpg\",\"http://c.hiphotos.bdimg.com/album/s%3D680%3Bq%3D90/sign=cdab1512d000baa1be2c44b3772bc82f/91529822720e0cf3855c96050b46f21fbf09aaa1.jpg\"]}]}";
			Gson gson = new Gson();
			DtqModelMsg msg = gson.fromJson(json, DtqModelMsg.class);
			return msg;
		}

		@Override
		protected void onPostExecute(DtqModelMsg result) {
			mAdapter = new DtqListAdapter(getActivity(), result.list);
			mListView.setAdapter(mAdapter);
		}

	}
}
